#include "widget.h"
#include "ui_widget.h"
#include "QDebug"
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    connect(ui->m_pbconvert,SIGNAL(clicked()),this,SLOT(DecToHex()));
}

Widget::~Widget()
{
    delete ui;
}

void Widget::DecToHex(void)
{
    QString srcText,dstText;
    QStringList srcData;
    bool ok;
    int dec;
    srcText = ui->m_teDec->toPlainText();
    srcData = srcText.split(" ");
    for(int i=0; i<srcData.size(); ++i)
    {
        if(srcData.at(i).isEmpty())
        {
            continue;
        }
        dec = srcData.at(i).toInt(&ok, 10);       // dec == 0, ok == false
        dstText.append(QString::asprintf("%02X ",dec));
    }
    ui->m_teHex->setText(dstText);
    return;
}
